<template>
  <div>
    <div class="table-operator" v-if="stage !== '05010' && stage !== '05050'">
      <a-upload
        name="file"
        :showUploadList="false"
        :multiple="false"
        :data="queryParam"
        :headers="tokenHeader"
        :action="url.importExcelUrl"
        @change="handleImportExcel"
        accept=".docx, .doc, .xlsx, .xls, .pdf, .jpeg, .png"
      >
        <a-button type="primary" style="background-color: #1ea489; border: 0">导入 </a-button>
      </a-upload>
      <a-button type="primary" style="background-color: #ffa500; border: 0" @click="OnExportList"> 导出 </a-button>
      <a-button type="primary" style="background-color: #1a91b3; border: 0" @click="OnExportTemp"> 模板下载 </a-button>
<!--      <a-popconfirm title="确定生成吗?" @confirm="() => create()">
        <a-button> 生成问题清单 </a-button>
      </a-popconfirm>-->
      <!-- <a-button type="primary" @click="showConfirm"> 提交审核 </a-button>
      <a-popconfirm title="确定生成吗?" @confirm="() => setApproveReason('1')">
        <a-button> 同意 </a-button>
      </a-popconfirm>
      <a-popconfirm title="确定生成吗?" @confirm="() => setApproveReason('2')">
        <a-button type="danger"> 拒绝 </a-button>
      </a-popconfirm> -->
      <!-- <a-button
        @click="handleGenerator"
        class="yellow_search_btn"
        style="color: white; margin-left: 18px; font-size: 700"
      >
        一键成稿
      </a-button> -->
    </div>
<!--    <div v-if="stage !== '05010' && stage !== '05050'" class="ant-alert ant-alert-info" style="margin-bottom: 16px">
      <i class="anticon anticon-info-circle ant-alert-icon"></i>已选择&nbsp;<a style="font-weight: 600">{{
        selectedRowKeys.length
      }}</a
      >项&nbsp;&nbsp;
      <a style="margin-left: 24px" @click="onClearSelected">清空</a>
    </div>-->
    <a-table
      ref="table"
      size="middle"
      bordered
      rowKey="id"
      :columns="columns"
      :dataSource="dataSource"
      :pagination="ipagination"
      :loading="loading"
      @change="handleTableChange"
    >
      <span slot="actionName">
        <a-button
          v-if="stage !== '05010' && stage !== '05050'"
          size="small"
          @click="handleAdd('新增底稿')"
          type="primary"
          icon="plus"
          >新增</a-button
        >
        <span v-else>操作</span>
      </span>
      <span v-if="stage !== '05010' && stage !== '05050'" slot="action" slot-scope="text, record">
        <a @click="handleEdit(record, '编辑底稿')">编辑</a>
        <a-divider type="vertical" />
        <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
          <a>删除</a>
        </a-popconfirm>
      </span>
      <span slot="action" slot-scope="text, record" v-else>
        <a-button type="link" @click="handleCheck(record, '查看')">查看</a-button>
      </span>
    </a-table>
    <CheckAndEditModel
      ref="modalForm"
      :id="id"
      :bsjdwName="bsjdwName"
      :bsjdw="bsjdw"
      :protype="protype"
      :type="type"
      @ok="modalFormOk"
    ></CheckAndEditModel>
    <SelectApprove ref="approver" :id="id" @submitData="handleSubmit"></SelectApprove>
    <SetReason ref="setReason" @approveReason="approveData"></SetReason>
  </div>
</template>

<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import CheckAndEditModel from './CheckAndEditModel'
import { httpAction, getAction } from '@/api/manage'
import { butStatus } from '../butStatus'
import columns from './indexColumns'
import SelectApprove from '../../public/SelectApprover'
import SetReason from '../../public/SetReason'

export default {
  props: ['id', 'bsjdwName', 'bsjdw', 'protype', 'type', 'stage', 'record'],
  name: 'sjdg',
  components: {
    CheckAndEditModel,
    SelectApprove,
    SetReason,
  },
  mixins: [JeecgListMixin, butStatus],
  data() {
    return {
      /* table选中keys*/
      selectedRowKeys: [],
      /* table选中records*/
      selectionRows: [],
      //表头
      queryParam: {
        proId: this.id,
        bsjdw: this.bsjdw,
      },
      thisTypeId: '71',
      columns: columns(this),
      url: {
        list: '/sjxmzygl/sjWorkZtfaEveDigao/queryProjectDraftList',
        delete: '/sjxmzygl/sjWorkZtfaEveDigao/remove',
        create: '/sjxmzygl/sjWorkZtfaEveDigao/turnDigaoToProblem',
        importExcelUrl: `${window._CONFIG['domianURL']}/sjxmzygl/sjWorkZtfaEveDigao/importExcel`,
        exportList: `${window._CONFIG['domianURL']}/sjxmzygl/sjWorkZtfaEveDigao/exportMatterInfo`,
        exportTemp: `${window._CONFIG['domianURL']}/sys/common/static/xls-template/dgxx.xlsx`,
        submit: '/sjxmzygl/sjWorkZtfaEveDigao/approveDigao',
        approve: '/sjxmzygl/sjWorkZtfaEveDigao/approveDigao',
      },
    }
  },
  methods: {
    onSelectChange(selectedRowKeys, selectionRows) {
      this.selectedRowKeys = selectedRowKeys
      this.selectionRows = selectionRows
    },
    onClearSelected() {
      this.selectedRowKeys = []
      this.selectionRows = []
    },
    create() {
      if (this.selectedRowKeys.length <= 0) {
        this.$message.warning('请选择一条记录！')
      } else {
        var ids = this.selectedRowKeys.toString()
        getAction(this.url.create, { ids: ids }).then((res) => {
          if (res.success) {
            this.loadData()
            this.$message.success(res.message)
          } else {
            this.loadData()
            this.$message.warning(res.message)
          }
        })
      }
    },
  },
}
</script>

<style scoped>
.yellow_search_btn {
  background-color: rgb(236, 149, 54);
  border-color: rgb(236, 149, 54);
}
</style>